package phapp.action.port;

import static javacommon.util.Struts2JsonHelper.outJson;
import static javacommon.util.Struts2JsonHelper.myWriterJson;
import java.io.IOException;
import java.util.*;

import javacommon.base.BaseStruts2Action; 
import javacommon.util.*;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import phapp.model.barapp.*;
import phapp.service.barapp.*;

/**
 * <p>标题: 系统对外接口
 * <p>描述: 接口中所有条件不传则表示无条件
 * @author you name
 * @version 1.0
 */

public class BarServiceAction extends BaseStruts2Action {
	
	
	/****************** 定义 begin  ********************/
	private String STATUSCODE = "statusCode";
	private String MESSAGE     = "message"; 
	private String statusCode  ="1000";
	private BarsManager barsManager;
	public void setBarsManager(BarsManager manager) {
		this.barsManager = manager;
	}
	private BarActManager barActManager;
	public void setBarActManager(BarActManager manager) {
		this.barActManager = manager;
	}
	private BarDeskManager barDeskManager;
	public void setBarDeskManager(BarDeskManager manager) {
		this.barDeskManager = manager;
	}
	private ShopMainManager shopMainManager;
	public void setShopMainManager(ShopMainManager manager) {
		this.shopMainManager = manager;
	}	
	private ShopGoodManager shopGoodManager;
	public void setShopGoodManager(ShopGoodManager manager) {
		this.shopGoodManager = manager;
	}	
	private VipMainManager vipMainManager;
	public void setVipMainManager(VipMainManager manager) {
		this.vipMainManager = manager;
	}	
	private VipJfshjyLogManager vipJfshjyLogManager;
	public void setVipJfshjyLogManager(VipJfshjyLogManager manager) {
		this.vipJfshjyLogManager = manager;
	}		
	private VipBarCreditManager vipBarCreditManager;
	public void setVipBarCreditManager(VipBarCreditManager manager) {
		this.vipBarCreditManager = manager;
	}	
	private BarOnlineManager barOnlineManager;
	public void setBarOnlineManager(BarOnlineManager manager) {
		this.barOnlineManager = manager;
	}	
	private VipFriendManager vipFriendManager;
	public void setVipFriendManager(VipFriendManager manager) {
		this.vipFriendManager = manager;
	}
	private BarChatLogManager barChatLogManager;
	public void setBarChatLogManager(BarChatLogManager manager) {
		this.barChatLogManager = manager;
	}	
	private VipAnnexManager vipAnnexManager;
	public void setVipAnnexManager(VipAnnexManager manager) {
		this.vipAnnexManager = manager;
	}		 
	private VipLogFriendManager  vipLogFriendManager;
	public void setVipLogFriendManager(VipLogFriendManager manager) {
		this.vipLogFriendManager = manager;
	}
	private FeedbackManager  feedbackManager;
	public void setFeedbackManager(FeedbackManager manager) {
		this.feedbackManager = manager;
	}
	private LyjFxmsgSendManager lyjFxmsgSendManager;

	/** 通过spring自动注入 */
	public void setLyjFxmsgSendManager(LyjFxmsgSendManager manager) {
	      this.lyjFxmsgSendManager = manager;
    }
	/****************** 定义 end  ********************/
	
	/*******************************************************/
	/******************   用户接口      ********************/
	/*******************************************************/

    /**
     * <p>标题: 会员注册
     * <p>参数: String sex:性别:1男,2女,String menberName:手机号码,String email:邮件,String fileType 文件类型,
     * <p>参数: String menberPass:密码,String nickname:昵称,String fileData:头像文件,String imei:手机MIME码
     * <p>返回: 
     * @see phapp.model.barapp.VipMain
     * @throws Exception
     */
	public void  regist() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	System.out.println("1\reitst begin");
    	/** HTTP参数处理 begin */
    	Map<String,Object> paramMap = getParamMap();
    	HttpServletRequest request = getRequest();
    	String menberName = request.getParameter("menberName");
    	String sex = request.getParameter("sex");
    	String menberPass = request.getParameter("menberPass");
    	String email = request.getParameter("email");
    	String nickname = request.getParameter("nickname");
    	String strFileData = request.getParameter("fileData");
    	String imei = request.getParameter("imei");
    	String fileType = request.getParameter("fileType");
    	/** HTTP参数处理 end */ 
    	System.out.println("2 HTTP参数处理 end ");
    	Map<String,Object> mapparam = new  HashMap<String,Object>();
    	mapparam.put("menberName", menberName);
    	System.out.println("3  查账户存在性 ");
    	List<VipMain> list  = vipMainManager.findList(mapparam);
    	if(null!=list&&list.size()>0){
    		result.put(STATUSCODE, "3001");
    		result.put(MESSAGE, "账号已存在");
    	}else{
        	/***/
    		System.out.println("4  准备生成文件 ");
        	FileManagerService fileserver = new FileManagerService();
        	Map<String,Object> fileMap = new  HashMap<String,Object>();
        	if(null!=fileType&&null!=strFileData){
        		System.out.println("5  参数有,开始生成文件 ");
        	    fileMap = fileserver.crateBtFile(strFileData, fileType,"user");
        	    
        	    String absolute = (String)fileMap.get("absolute");
        	    String relatively = (String)fileMap.get("relatively");
        	    System.out.println("6   生成文件 : "+absolute);
        	    System.out.println("absolute="+absolute);
        	    System.out.println("relatively="+relatively);
        	    paramMap.put("file",absolute);
        	    paramMap.put("elephant", relatively);
        	    paramMap.put("fileType", fileType);
        	}else{
        		System.out.println("7   无参数，用 : ");
        	    paramMap.put("file","/app/tjapp/tomcat-7.0.29/webapps/bar/upload/elephant/avatar_w_60px.png");
        	    paramMap.put("elephant", "http://117.40.178.58:7070/bar/upload/elephant/avatar_w_60px.png");
        	    paramMap.put("fileType", "png");
        	}
    		//map.get("btFile");        //BASE6流
    		//map.get("absolute");  //绝对
    		//map.get("relatively");//相对
        	/**   重新封装 begin */
        	//paramMap.put("file",fileMap.get("absolute"));
        	//paramMap.put("elephant", fileMap.get("relatively"));
        	System.out.println("10   重新封装 : ");
        	paramMap.put("roses", "1");
        	paramMap.put("logincount", "1");
        	paramMap.put("pinyin4j", "B");  //暂默认
        	/**  数据验证与重新封装 end */
        	VipMain bean = new VipMain();
        	bean.setMenberName(menberName);
        	paramMap.put("menberName", menberName);
        	
	    	boolean bool = vipMainManager.vipReg(paramMap);
	    	System.out.println("11  写完注册表,end ");
	    	result.put(STATUSCODE, statusCode);
			result.put(MESSAGE, "恭喜您！注册成功");
    	}
    	outJson(result);
    }
    /**
     * <p>标题: 会员登录
     * <p>参数: String menberName:手机号码,String menberPass:密码,
     * <p>参数: String imei手机串码 ,客户端系统类型	systemType,客户端系统版本	systemVersion,
     * <p>参数: 客户端版本号	version,手机类型	terminalType
     * <p>返回: {MESSAGE:statusCode,"STATUSCODE":true}
     * <p>返回: 最新版本号	latestVersion	字符串，最新版本号
     * <p>返回: 最新版本路径	versionUrl	字符串
     * <p>返回: 最新版本描述	versionDesc	字符串
     * <p>返回: 客户头像	elephant	字符串
     * <p>返回: Apk大小	fileSize	文件大小（android版用）整型
     * @see phapp.model.barapp.VipMain
     * @throws Exception
     */
	public void  login() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */    	 
    	Map<String,String> paramMap = getParamMap();
    	HttpServletRequest request = getRequest();
    	String menberName = request.getParameter("menberName");
    	String menberPass = request.getParameter("menberPass");
    	String imei = request.getParameter("imei");
    	String systemType = request.getParameter("systemType");
    	String systemVersion = request.getParameter("systemVersion");
    	String version = request.getParameter("version");
    	String terminalType = request.getParameter("terminalType");
    	paramMap.put("menberName",menberName);
    	paramMap.put("menberPass",menberPass);
    	/** HTTP参数处理 end */  
    	  
    	List<VipMain> list = vipMainManager.findList(paramMap);
    	if(null!=list&&list.size()==1){
    		Map<String,Object> xx_paramMap = new HashMap<String,Object>();
    		VipMain vipMainBean = list.get(0);
    		result.put(STATUSCODE, statusCode);
    		result.put(MESSAGE, "登录成功");
    		VipMain obj = vipMainBean;
    		obj.setMenberName(paramMap.get("menberName"));
    		obj.setLogincount(1);
    		xx_paramMap.put("logincount", "1");
    		xx_paramMap.put("id", obj.getId());
    		result.put("result","");
    		result.put("latestVersion","");
    		result.put("versionUrl","");
    		result.put("versionDesc","");
    		result.put("elephant",((VipMain)list.get(0)).getFile());
    		result.put("baseImg","");
    		result.put("fileSize","");
    		result.put("menberId",vipMainBean.getId());
    		result.put("menberName",vipMainBean.getMenberName());
    		result.put("pinyin4j",vipMainBean.getPinyin4j());
    		result.put("nickname",vipMainBean.getNickname());
    		result.put("sex",vipMainBean.getSex());
    		result.put("mood",vipMainBean.getMood());
    		result.put("constellation",vipMainBean.getConstellation());
    		result.put("age",vipMainBean.getAge());
    		result.put("file",vipMainBean.getFile());
    		result.put("elephant",vipMainBean.getElephant());
    		result.put("roses",vipMainBean.getRoses());
    		result.put("logincount",vipMainBean.getLogincount());
    		//result.put("vipMainBean", vipMainBean);
    		vipMainManager.updateByMap(xx_paramMap); 
    	}else{
    		result.put(STATUSCODE, false);
    		result.put(MESSAGE, "登录失败");
    	}
    	outJson(result);
    }
    /**
     * <p>标题: 个人资料修改  
     * <p>参数: String id 会员ID,String mood 心情,String constellation 星座,String age 年龄
     * <p>参数: String sex:性别:1男,2女,String menberName:手机号码,String email:邮件,String fileType 文件类型,
     * <p>参数: String menberPass:密码,String nickname:昵称,String file:头像文件,String imei:手机MIME码
     * <p>返回: {MESSAGE:statusCode,"STATUSCODE":true}
     * @see phapp.action.uploads.AjaxUpload 
     * @see phapp.model.barapp.VipMain
     * @throws Exception
     */
	public void  updateCustom() throws Exception{
    	
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	Map<String,Object> paramMap = getParamMap();
    	HttpServletRequest request = getRequest();
    	String menberName = request.getParameter("menberName");
    	String sex = request.getParameter("sex");
    	String menberPass = request.getParameter("menberPass");
    	String email = request.getParameter("email");
    	String nickname = request.getParameter("nickname");
    	String strFileData = request.getParameter("file");
    	String imei = request.getParameter("imei");
    	String fileType = request.getParameter("fileType");
    	String id = request.getParameter("id");
    	String mood = request.getParameter("mood");
    	String constellation = request.getParameter("constellation");
    	String age = request.getParameter("age");
    	/** HTTP参数处理 end */ 
    	/************************* 重新封装 begin */
    	if(StringTool.isNull(id)==true){
	    	VipMain bean = vipMainManager.getById(Integer.parseInt(id));
	    	/** 头象 begin */
	    	FileManagerService fileserver = new FileManagerService();
	    	Map<String,Object> fileMap = new  HashMap<String,Object>();
	    	if(null!=fileType&&null!=strFileData){
	    	    fileMap = fileserver.crateBtFile(strFileData, fileType,"user");
        	    String absolute = (String)fileMap.get("absolute");
        	    String relatively = (String)fileMap.get("relatively");
        	    System.out.println("create new file:绝对 absolute: "+absolute); 
        	    System.out.println("create new file: 相对 relatively:"+relatively);	    	    
	    	    bean.setFile(absolute);//绝对
	    	    bean.setElephant(relatively);//相对
	    	    bean.setFileType(fileType);
	    	} 
	    	/** 头象 end */
	    	bean.setPinyin4j("B");  //暂默认
	    	bean.setMenberName(menberName);
	    	//bean.setSex(sex);
	    	bean.setMenberPass(menberPass);
	    	bean.setEmail(email);
	    	bean.setNickname(nickname);
	    	bean.setImei(imei);
	    	bean.setMood(mood);
	    	bean.setConstellation(constellation);
	    	bean.setAge(age);
	    	/**  数据验证与重新封装 end */
		    vipMainManager.update(bean);
		    result.put(STATUSCODE, statusCode);
		    result.put(MESSAGE, "恭喜您！注册成功");		    
    	}else{
    	    result.put(STATUSCODE, "8888");
    	    result.put(MESSAGE, "参数格式错误");
    	}    	
    	outJson(result);
    }
    /**
     * <p>标题: 修改好友备注 
     * <p>参数: String mainId 会员ID(当前用户) , String passiveUserId 被加者ID(好友) ,String remark 备注名 
     * <p>返回: {MESSAGE:"修改成功","STATUSCODE":"1000"}
     * @see phapp.model.barapp.VipFriend
     * @throws Exception
     */
	public void  updateRemark() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String mainId = request.getParameter("menberId");
    	String passiveUserId = request.getParameter("passiveUserId");
    	String beizhuName = request.getParameter("remark");
    	
    	paramMap.put("mainId", mainId);
    	paramMap.put("passiveUserId", passiveUserId);
    	List list1= vipFriendManager.findList(paramMap);
    	if(null!=list1&&list1.size()>0){
    		VipFriend vipFriend = (VipFriend)list1.get(0);
    		vipFriend.setBeizhuName(beizhuName);
    		vipFriendManager.update(vipFriend);
    		result.put(STATUSCODE, statusCode);
    		result.put(MESSAGE, "修改成功"); 
    	}else{
    		result.put(STATUSCODE, "3000");
    		result.put(MESSAGE, "修改失败"); 
    	}    	   	
    	outJson(result);
	}
    /**
     * <p>标题: 查询所有会员,返回列表
     * <p>参数: String sex:性别:1男,2女; String barId  酒吧Id 
     * <p>返回:
     * @throws Exception
     */
    public void  getVipAllList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String sex = request.getParameter("sex");
    	paramMap.put("sex", sex);
    	List list = vipMainManager.getVipAllList(paramMap);
    	/** HTTP参数处理 end */
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "成功");
		result.put("list", list);
    	outJson(result);
    }
    /**
     * <p>标题:  通讯录-我的好友会员列表
     * <p>参数: String menberId  会员,String limit:取前多少条
     * <p>描述: 以字母排序列表
     * <p>返回: {"list":[{VipFriend}]
     * @see phapp.model.barapp.VipFriend
     * @throws Exception
     */
    public void  getVipFriendList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String menberId = request.getParameter("menberId"); 
    	paramMap.put("myFriendId1", menberId); 
    	paramMap.put("myFriendId2", menberId); 
    	List<VipMain> list = vipMainManager.myFriendList(paramMap);
    	List listdata = new ArrayList();
    	for(VipMain obj : list){
    		Map<String,Object> oneleMap = new HashMap<String,Object>();
    		
    		//oneleMap.put("id",obj.getId());
    		//oneleMap.put("beizhuName" , obj.getBeizhuName());
    		//oneleMap.put("menberId" , obj.getPassiveUserId());
    		/** 主类处理 */
    		VipMain vipMain = obj ;
    		oneleMap.put("menberId",vipMain.getId());
    		oneleMap.put("menberName",vipMain.getMenberName()); 
    		oneleMap.put("elephant" ,vipMain.getElephant());
    		oneleMap.put("nickname" ,vipMain.getNickname());
    		oneleMap.put("sex" ,vipMain.getSex());
    		oneleMap.put( "mood" ,vipMain.getMood());
    		oneleMap.put("constellation" ,vipMain.getConstellation());
    		oneleMap.put("age" ,vipMain.getAge());
    		oneleMap.put("roses", vipMain.getRoses()); 
    		oneleMap.put("imei", vipMain.getImei()); 
    		//paramMap.put("file" ,vipMain.getFile());
    		oneleMap.put("pinyin4j" ,vipMain.getPinyin4j());
    		oneleMap.put("email" ,vipMain.getEmail());
    		oneleMap.put("fileType" ,vipMain.getFileType());
    		oneleMap.put("logincount" ,vipMain.getLogincount());
    		listdata.add(oneleMap); 
    	}    	
    	/** HTTP参数处理 end */
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "成功");
		result.put("list", listdata);
    	outJson(result);
    }
    /**
     * <p>标题: 修改我的在线信息(酒吧、台桌)
     * <p>参数: String barId  酒吧Id ,String menberId 会员ID , String  deskId 吧台ID  
     * <p>描述: 
     * <p>返回: {MESSAGE:"成功","STATUSCODE":1000 }
     * @see phapp.model.barapp.BarOnline
     * @throws Exception
     */
    public void  updateMeOnline() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	String barId = request.getParameter("barId");
    	String menberId = request.getParameter("menberId");
    	String deskId = request.getParameter("deskId");;
    	barOnlineManager.updateMeOnline(barId ,menberId, deskId);
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "成功"); 
    	outJson(result);
    }
    /**
     * <p>标题: 查询 在线人员 列表
     * <p>参数: String barId  酒吧Id ,String menberId 会员ID, String sex:性别:1男,2女 ,String control 1:查好友,2:取非好友 ,String limit:取前多少条
     * <p>参数: String  deskId 吧台ID, String totalCount 第几页, String pageSize 每页显示数
     * <p>参数: String wifiname 酒吧WIFI名称 , String deskName 台桌名
      * <p>描述: 按三个条件组合查询数据,例:查询酒吧1,前5个男性好友则(barId=1,sex=1,control=1,limit=5)
     * <p>描述: 
     * <p>返回: {"list":[{BarOnline}]
     * @see phapp.model.barapp.BarOnline
     * @throws Exception
     */
    public void  getBarOnlineList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,Object> paramMap = new HashMap<String,Object>();
    	String barId = request.getParameter("barId");
    	String sex = request.getParameter("sex");
    	String control = request.getParameter("control");
    	String limit = request.getParameter("limit");
    	String deskId = request.getParameter("deskId");//(废弃中)
    	String deskName =(null== request.getParameter("deskName") ) ? "1" :  request.getParameter("deskName") ;
    	String totalCount = request.getParameter("totalCount");
    	String pageSize = request.getParameter("pageSize");
    	String menberId = request.getParameter("menberId");
    	String wifiname = request.getParameter("wifiname");
    	paramMap.put("barId", barId);
    	paramMap.put("sex", sex);
    	paramMap.put("control", control);
    	paramMap.put("limit", limit);
    	paramMap.put("deskName", deskName);
    	/**deskId 如果用户通过桌台，说明它已经进入此桌*/
    	if(javacommon.util.StringTool.isNumeric(barId)&&javacommon.util.StringTool.isNumeric(menberId)){
    		barOnlineManager.updateMeOnline(barId ,menberId, deskName);
    	}
    	//Map 说明: String barId  酒吧 Id String sex 性别:1男,2女 ,String control 1:查好友,2:取非好友 , String limit 取前多少条
    	List<BarOnline> list = barOnlineManager.getBarOnlineList(paramMap);
    	List listdata = new ArrayList();
    	Map<String,Object> paramMap2 = new HashMap<String,Object>();
    	paramMap2.put("myFriendId1",menberId );
    	paramMap2.put("myFriendId2",menberId );
    	List<VipMain> listVipFriend = vipMainManager.myFriendList(paramMap2);
    	
    	for(BarOnline onle : list){
    		int aa = 0;
    		Map<String,Object> oneleMap = new HashMap<String,Object>(); 
    		int onleMenberId = onle.getMenberId();
    		oneleMap.put("id",onle.getId());
    		oneleMap.put("deskId" ,onle.getDeskId());
    		oneleMap.put("menberId" ,onleMenberId);
    		oneleMap.put("barId" ,onle.getBarId());
    		oneleMap.put("likes" ,onle.getLikes());
    		VipMain vipMain = onle.getVipMain();
  
    		oneleMap.put("menberName",vipMain.getMenberName()); 
    		oneleMap.put("elephant" ,vipMain.getElephant());
    		oneleMap.put("nickname" ,vipMain.getNickname());
    		oneleMap.put("sex" ,vipMain.getSex());
    		oneleMap.put( "mood" ,vipMain.getMood());
    		oneleMap.put("constellation" ,vipMain.getConstellation());
    		oneleMap.put("age" ,vipMain.getAge());
    		oneleMap.put("roses", vipMain.getRoses()); 
    		//paramMap.put("file" ,vipMain.getFile());
    		oneleMap.put("pinyin4j" ,vipMain.getPinyin4j());
    		oneleMap.put("email" ,vipMain.getEmail());
    		oneleMap.put("fileType" ,vipMain.getFileType());
    		oneleMap.put("logincount" ,vipMain.getLogincount());
    		/** 增加 好友辨别 begin */
    		for(int i=0;i<listVipFriend.size();i++){
    			VipMain vipMain2 = listVipFriend.get(i);
    			if(onleMenberId==vipMain2.getId()){
    				oneleMap.put("control" ,"1");
    				aa=1;
    				break;
    			}
    		}
    		if(javacommon.util.StringTool.isNumeric(menberId)&&onleMenberId==Integer.parseInt(menberId)){
    			oneleMap.put("control" ,"3");
        	}else if(aa==0){
    			oneleMap.put("control" ,"2");
    		}
    		/** 增加 好友辨别 end */
    		listdata.add(oneleMap); 
    	}
    	/*** HTTP参数处理 end */
    	
    	/****************修改在线数据 begin */
    	/** 1、增加积分  */
    	Map<String,Object> paramMap3 = new HashMap<String,Object>();
    	paramMap3.put("recipientId",menberId);
    	paramMap3.put("mainId",barId);
    	paramMap3.put("types",1);
    	paramMap3.put("timelimit","1");
    	List lsitlog = vipJfshjyLogManager.findList(paramMap3); 
    	int addcredit = 10;  //初始每天增加积分默认值
    	if(null==lsitlog||lsitlog.size()==0){
        	paramMap3.clear();
        	paramMap3.put("vipId", menberId);
        	paramMap3.put("barId", barId);
    		List listCredit1 = vipBarCreditManager.findList(paramMap3);
    		if(null!=listCredit1&&listCredit1.size()>0){
    			VipBarCredit vipBarCredit = (VipBarCredit)listCredit1.get(0);
    			paramMap3.clear();
    			paramMap3.put("id", vipBarCredit.getId());
    			paramMap3.put("addcredit", addcredit);
    			vipBarCreditManager.updateByMap(paramMap3);
    		}else{
        		VipBarCredit vipBarCredit = new VipBarCredit();
        		vipBarCredit.setBarId(Integer.parseInt(barId));
        		vipBarCredit.setVipId(Integer.parseInt(menberId));
        		vipBarCredit.setCredit(addcredit);
    			vipBarCreditManager.save(vipBarCredit);
    		}
    		VipJfshjyLog vipJfshjyLog = new VipJfshjyLog();
    		vipJfshjyLog.setMainId(Integer.parseInt(barId));
    		vipJfshjyLog.setRecipientId(Integer.parseInt(menberId));
    		vipJfshjyLog.setTypes("1");
    		vipJfshjyLogManager.save(vipJfshjyLog);
    	}
    	
    	/****************修改在线数据 end   */
    	
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "成功");
		result.put("list", listdata);
    	outJson(result);
    }
    /**
     * <p>标题: 1.1	取回（重置）密码
     * <p>参数: String menberId  会员ID  
     * <p>返回: {MESSAGE:statusCode,"STATUSCODE":true}
     * @see phapp.model.barapp.VipMain
     * @throws Exception
     */
    public void  resetPasswd() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String menberId = request.getParameter("menberId");
    	String menberPass = "888888";//request.getParameter("menberPass"); 
    	VipMain vipMain = new VipMain();
    	vipMain.setId(Integer.parseInt(menberId));
    	vipMain.setMenberPass(menberPass);
    	vipMainManager.update(vipMain);
    	/** HTTP参数处理 end */
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, statusCode);
		result.put("password", menberPass);
    	outJson(result);
    }	
    /**
     * <p>标题:  加为好友/新朋友添加
     * <p>参数: String mainId  主动者会员Id ,String recipientId 被加者会员Id ,String verifyContent 发送的消息,String roses 鲜花数
     * <p>描述: 
     * <p>返回: {MESSAGE:statusCode,"STATUSCODE":true}
     * @see phapp.model.barapp.vipFriend
     * @see phapp.model.barapp.vipMain
     * @see phapp.model.barapp.vipJfshjyLog
     * @throws Exception
     */
    public void  addFriend() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	Map<String,String> paramMap = getParamMap(); 
    	/** Map To PoJo */
    	VipLogFriend vipLogFriend =  (VipLogFriend)MapForObj.convertMap(VipLogFriend.class, paramMap);
    	/** HTTP参数处理 end */
    	/** 修改人的鲜花数 begin */
//    	VipMain vipMain = new VipMain();
        /** 暂未实现*/
//    	vipMainManager.update(vipMain);
    	/** 修改人的鲜花数 end */
    	
    	/** 会员交友日志表 begin */
    	//状态或流程:1申请,2同意,3不同意,4删除好友,5黑名单,6其它
    	vipLogFriend.setCircuit("1");
    	vipLogFriendManager.save(vipLogFriend);    	
    	/** 会员交友日志表 end */
    	
    	/**推送表-好比短信下行表 begin */
    	LyjFxmsgSend lyjFxmsgsend = new LyjFxmsgSend();
    	   /**消息类型:3图片广本 4赠花*/
    	lyjFxmsgsend.setMsgType(7); 
    	   /**发送者ID*/
    	lyjFxmsgsend.setSendId(Integer.parseInt( vipLogFriend.getMainId()));
    	   /**接收者ID*/
    	lyjFxmsgsend.setRecvId(Integer.parseInt( vipLogFriend.getRecipientId()) );
    	   /**消息格式:1文本 2图片*/
    	lyjFxmsgsend.setMsgFormat(1);
    	   /**消息内容(图片url)*/
    	lyjFxmsgsend.setMsgContent("有人加你");
    	   /**玫瑰花数量*/
    	lyjFxmsgsend.setFlowerCount(0);
    	//其他初始值，必须要赋值
        lyjFxmsgsend.setMsgLength(0);
        lyjFxmsgsend.setMsgSeqno(0);
        lyjFxmsgsend.setMsgSeqno(0);
        lyjFxmsgsend.setOrigMsgSeqno(0);
        lyjFxmsgsend.setSendCount(0);
        lyjFxmsgsend.setSendStatus(-1); 
    	lyjFxmsgSendManager.save(lyjFxmsgsend);
    	/**推送表-好比短信下行表 end */
    	
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "已经发送请求");
    	outJson(result);
    }
    
    /**
     * <p>标题: 通讯录-新的朋友/验证消息-列表
     * <p>参数: String menberId  会员ID
     * <p>描述: 
     * <p>返回: {MESSAGE:statusCode,"STATUSCODE":1000,"list":{[VipLogFriend]} }
     * @see phapp.model.barapp.VipLogFriend
     * @see phapp.model.barapp.vipMain 
     * @throws Exception
     */
    public void  getNewFriendList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String menberId = request.getParameter("menberId"); 
    	paramMap.put("recipientId", menberId);
    	paramMap.put("circuit", "1"); //状态或流程:1申请,2同意,3不同意,4删除好友,5黑名单,6其它    	 
    	List<VipLogFriend> list = vipLogFriendManager.getNewFriendList(paramMap);
    	List listdata = new ArrayList();
    	for(VipLogFriend obj : list){
    		Map<String,Object> oneleMap = new HashMap<String,Object>();
    		
    		oneleMap.put("id",obj.getId());
    		oneleMap.put("circui" ,obj.getCircuit());
    		oneleMap.put("menberId" ,obj.getMainId());
    		oneleMap.put("handselRoses" ,obj.getRoses());
    		oneleMap.put("verifyContent" ,obj.getVerifyContent());
    		/**主类处理*/
    		VipMain vipMain = obj.getVipMain(); 
    		oneleMap.put("menberName",vipMain.getMenberName()); 
    		oneleMap.put("elephant" ,vipMain.getElephant());
    		oneleMap.put("nickname" ,vipMain.getNickname());
    		oneleMap.put("sex" ,vipMain.getSex());
    		oneleMap.put( "mood" ,vipMain.getMood());
    		oneleMap.put("constellation" ,vipMain.getConstellation());
    		oneleMap.put("age" ,vipMain.getAge());
    		oneleMap.put("roses", vipMain.getRoses()); 
    		//paramMap.put("file" ,vipMain.getFile());
    		oneleMap.put("pinyin4j" ,vipMain.getPinyin4j());
    		oneleMap.put("email" ,vipMain.getEmail());
    		oneleMap.put("fileType" ,vipMain.getFileType());
    		oneleMap.put("logincount" ,vipMain.getLogincount());
    		listdata.add(oneleMap);
    		 
    	}    	
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "已经发送请求");
		result.put("list", listdata);
    	outJson(result);
    } 

    /**
     * <p>标题: 	获取客户资料
     * <p>参数: String menberId   会员Id 或者 String user   会员登录名
     * <p>描述: 
     * <p>返回: {MESSAGE:"","STATUSCODE":1000,"data":[{VipMain}]}
     * @see phapp.model.barapp.VipMain
     * @throws Exception
     */
    public void  getCustom() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String id = request.getParameter("menberId"); 
    	String menberName = request.getParameter("user"); 
    	
    	paramMap.put("id", id);
    	paramMap.put("menberName", menberName); 
    	/** HTTP参数处理 end */
    	List<VipMain> list = vipMainManager.findList(paramMap);
    	List listData = new ArrayList();
    	Map<String,Object> oneleMap = new HashMap<String,Object>();
    	if(null!=list&&list.size()>0){ 
    		VipMain vipMain = list.get(0);
    		oneleMap.put("menberName",vipMain.getMenberName()); 
    		oneleMap.put("elephant" ,vipMain.getElephant());
    		oneleMap.put("nickname" ,vipMain.getNickname());
    		oneleMap.put("sex" ,vipMain.getSex());
    		oneleMap.put( "mood" ,vipMain.getMood());
    		oneleMap.put("constellation" ,vipMain.getConstellation());
    		oneleMap.put("age" ,vipMain.getAge());
    		oneleMap.put("roses", vipMain.getRoses()); 
    		//paramMap.put("file" ,vipMain.getFile());
    		oneleMap.put("pinyin4j" ,vipMain.getPinyin4j());
    		oneleMap.put("email" ,vipMain.getEmail());
    		oneleMap.put("fileType" ,vipMain.getFileType());
    		oneleMap.put("logincount" ,vipMain.getLogincount());
    		oneleMap.put("menberId" ,vipMain.getId());
        	result.put(STATUSCODE, statusCode);
    		result.put(MESSAGE, "获取成功");    		
    	}else{
        	result.put(STATUSCODE, "3000");
    		result.put(MESSAGE, "获取失败");
    	}
		result.put("data", oneleMap);
    	outJson(result);
    }
    
    /**
     * <p>标题: 获取客户相册
     * <p>参数: String menberId   会员Id 
     * <p>描述: 
     * <p>返回: {MESSAGE:"","STATUSCODE":1000,"list":[{VipAnnex}]}
     * @see phapp.model.barapp.VipMain
     * @see phapp.model.barapp.VipAnnex
     * @throws Exception
     */
    public void  getAlbum() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String menberId = request.getParameter("menberId"); 
    	paramMap.put("mainId", menberId);  
    	/** HTTP参数处理 end */
    	List<VipAnnex> list = vipAnnexManager.findList(paramMap);
    	List listData = new ArrayList();
    	for( VipAnnex obj :  list ){
    		Map<String,String> dataMap = new HashMap<String,String>();
    		dataMap.put("url", obj.getUrl());
    		dataMap.put("menberId", menberId);
    		dataMap.put("id",String.valueOf(obj.getId()));
    		listData.add(dataMap);
    	}
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "获取相册成功");
		result.put("list", listData);
    	outJson(result);
    }
    /**
     * <p>标题: 客户相册管理(新增、删除)
     * <p>参数: String menberId   会员Id 
     * <p>参数: String file    文件流(新增时加流)
     * <p>参数: String ablumId    相片ID(无ID表示新增、有ID表示删除)
     * <p>参数: String filetype   文件类型
     * <p>描述: 
     * <p>返回: {MESSAGE:"","STATUSCODE":1000,"data":{VipAnnex}}
     * @see phapp.model.barapp.VipMain
     * @see phapp.model.barapp.VipAnnex 
     * @throws Exception
     */
    public void  albumManager() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest(); 
    	String menberId = request.getParameter("menberId");
    	String ablumId = request.getParameter("ablumId");
    	String strFileData = request.getParameter("file");
    	String fileType = request.getParameter("fileType");
    	/***/
    	FileManagerService fileserver = new FileManagerService();
    	Map<String,Object> fileMap = new  HashMap<String,Object>();
    	if(null!=ablumId&&ablumId.length()>0){
    		//修改 FileManagerService
    		VipAnnex obj = vipAnnexManager.getById(Integer.parseInt(ablumId));
    		//删除文件
    		fileserver.deleteFile(obj.getFile());
        	if(null!=fileType&&null!=strFileData){
      	      	fileMap = fileserver.crateBtFile(strFileData, fileType,"good");
      	    }
        	obj.setFile((String)fileMap.get("absolute")  ); //绝对
        	obj.setUrl( (String)fileMap.get("relatively")); //相对
        	vipAnnexManager.update(obj);
        	result.put("data", obj);
    	}else {
    		VipAnnex obj = new VipAnnex();
        	if(null!=fileType&&null!=strFileData){
      	      	fileMap = fileserver.crateBtFile(strFileData, fileType,"good");
      	    }
        	obj.setMainId(Integer.parseInt(menberId));
        	obj.setFile((String)fileMap.get("absolute")  ); //绝对
        	obj.setUrl( (String)fileMap.get("relatively")); //相对
        	vipAnnexManager.save(obj);
        	result.put("data", obj);
    	}
    	
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "操作相册成功");
    	outJson(result);
    }
    /**
     * <p>标题: 通过验证｜拒绝添加-新朋友请求
     * <p>参数: String mainId  主动者会员Id ,String recipientId 被加者会员Id,String beizhuName 备注名,String circuit 状态或流程:1申请,2同意,3不同意,4删除好友,5黑名单,6其它
     * <p>描述:  
     * <p>返回: {"MESSAGE" : msg,"STATUSCODE":1000 }
     * @see phapp.model.barapp.VipLogFriend
     * @see phapp.model.barapp.VipFriend
     * @see phapp.model.barapp.vipMain
     * @throws Exception
     */
    public void  verifyFriend() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String mainId = request.getParameter("mainId");
    	String recipientId = request.getParameter("recipientId");
    	String circuit = request.getParameter("circuit");
    	String beizhuName = request.getParameter("beizhuName");
    	String verifyId = request.getParameter("verifyId");
    	/** HTTP参数处理 end */
    	paramMap.put("mainId",recipientId);
    	paramMap.put("recipientId",  mainId);
    	paramMap.put("circuit", circuit);
    	if(StringTool.isNull(mainId)==true && StringTool.isNull(recipientId)==true){
    		/**添加好友通过之后，插一条记录到t_fxmsg_send*/
    		LyjFxmsgSend fxmsg = new LyjFxmsgSend();
	    	if("2".equals(circuit)){
	    		/***/
	    		vipLogFriendManager.verifyFriend(paramMap);
	    		VipFriend vipFriend  = new VipFriend();
	    		vipFriend.setMainId(Integer.parseInt(mainId));
	    		vipFriend.setPassiveUserId(Integer.parseInt(recipientId));
	    		vipFriend.setStatuss("2");
	    		vipFriend.setBeizhuName(beizhuName);
	    		vipFriendManager.save(vipFriend);
	    		
	    		fxmsg.setVerifyStatus(1);
	    		result.put(STATUSCODE, statusCode);
	    		result.put(MESSAGE, "您成功添加他|他为好友,赶紧聊天吧");
	    	}else if("3".equals(circuit)){
	    		fxmsg.setVerifyStatus(0);
	    		vipLogFriendManager.verifyFriend(paramMap);
	    		result.put(STATUSCODE, statusCode);
	    		result.put(MESSAGE, "您成功拒绝他|她的请求");
	    	}
	    	fxmsg.setRecvId(Integer.parseInt(mainId)); //为请求者
    		fxmsg.setSendId(Integer.parseInt(recipientId));  //为批准的人
    		fxmsg.setMsgType(6);
        	//其他初始值，必须要赋值
    		fxmsg.setMsgLength(0);
    		fxmsg.setMsgSeqno(0);
    		fxmsg.setMsgSeqno(0);
    		fxmsg.setOrigMsgSeqno(0);
    		fxmsg.setSendCount(0);
    		fxmsg.setSendStatus(-1);
            
    		lyjFxmsgSendManager.save(fxmsg);
    	
    	}else{	
    		result.put(MESSAGE, "数据格式错误");
    		result.put(STATUSCODE, "8888");
    	}
    	 
    	outJson(result);
    }
	
    
    
	/*******************************************************/
	/******************     酒吧接口    ********************/
	/*******************************************************/
    
    
    /**
     * <p>标题: 酒吧接口-查询所有酒吧列表数据
     * <p>参数:
     * <p>返回:{"list":[{Bars}],"STATUSCODE":true}
     * @see phapp.model.barapp.Bars
     * @throws Exception
     */
    public void  getBarAll() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
		List<Bars> dataList = barsManager.findAll();
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "读取成功");
		result.put("list", dataList);
		outJson(result);
    }
    /**
     * <p>标题: 酒吧接口-查询某个酒吧所有信息
     * <p>参数: String barId  酒吧 Id
     * <p>返回:{"obj":{Bars},"STATUSCODE":true}
     * @see phapp.model.barapp.Bars
     * @see phapp.model.barapp.BarOnline
     * @throws Exception
     */
    public void  getBarById() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	Map<String,Object> dataMap = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest();
    	String barId = request.getParameter("barId");
		Bars  obj = barsManager.getBarAllById(barId);
		int womancount=0;
		int mancount=0;
		dataMap.put("barId", barId);
 		List<BarOnline> listonle = barOnlineManager.getBarOnlineList(dataMap);
		dataMap.clear();
		for(int i=0;i<listonle.size();i++){
			BarOnline barOnline = listonle.get(i);
			
			if(null!=barOnline){
				VipMain vipMain = barOnline.getVipMain();
				if(null!=vipMain){
					//性别:1男,2女
					if("1".equals(vipMain.getSex())){
						mancount++;
					}else  if("2".equals(vipMain.getSex())){
						womancount++;
					}
				}
			}
		}

		Bars  obj1 = new Bars();
		List<BarAnnex> listAnnel = obj.getAnnexList();
		obj1 = obj;
		obj1.setAnnexList(null);
		dataMap = MapForObj.convertBean(obj1);
		dataMap.put("womancount",womancount);
		dataMap.put("mancount",mancount);
		/**在线人*/
		
		List listAnne2 = new ArrayList();
		for( BarAnnex annex2  : listAnnel    ){
			Map<String,Object> data3 = new HashMap<String,Object>();
			data3.put("explains", "");
			data3.put("url", annex2.getUrl());
			listAnne2.add(data3);
		}
		dataMap.put("annexList", listAnne2);
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "读取成功");
		result.put("data", dataMap);
		outJson(result);
		
    }
	
    /**
     * <p>标题: 酒吧 最新活动　列表数据
     * <p>参数: String barId  酒吧 Id
     * <p>返回:{"list":[{BarAct}],"STATUSCODE":true}
     * @see phapp.model.barapp.BarAct
     * @throws Exception
     */
    public void  getNewActList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest();
    	String id = request.getParameter("barId");
    	BarAct  objParam =  new BarAct();
		List<BarAct> list = barActManager.findListByBean(objParam);
		result.put(STATUSCODE, statusCode);
		result.put("list", list);
		outJson(result);
    }
    /**
     * <p>标题: 酒吧 吧台(桌台)　列表数据
     * <p>参数: String barId  酒吧 Id
     * <p>返回:{"list":[{BarDesk}],"STATUSCODE":true}
     * @see phapp.model.barapp.BarDesk
     * @throws Exception
     */
    public void  getBarDeskList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest();
    	String barId = request.getParameter("barId");
    	Map<String,String> paramMap = new HashMap<String,String>();
    	paramMap.put("barId", barId);
		List<BarDesk> list = barDeskManager.findListOnile(paramMap);
		result.put(STATUSCODE, statusCode);
		result.put("list", list);
		outJson(result);
    }
    /**
     * <p>标题: 酒吧积分详情(积分日志)　列表数据
     * <p>参数: String barId  酒吧 Id,String vipId 会员ID
     * <p>返回:{"list":[{VipJfshjyLog}],"STATUSCODE":true}
     * @see phapp.model.barapp.VipJfshjyLog
     * @throws Exception
     */
    public void  getCreditLogList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest();
    	String barId = request.getParameter("barId");
    	String vipId = request.getParameter("vipId");
    	VipJfshjyLog  vipJfshjyLog = new VipJfshjyLog();
    	vipJfshjyLog.setTypes("1");
    	vipJfshjyLog.setMainId(Integer.parseInt(vipId));
    	vipJfshjyLog.setRecipientId(Integer.parseInt(barId));
		List<VipJfshjyLog> list = vipJfshjyLogManager.findListByBean(vipJfshjyLog);
		result.put(STATUSCODE, statusCode);
		result.put("list", list);
		outJson(result);
    }	
    /**
     * <p>标题: 酒吧积分 列表数据
     * <p>参数: String barId  酒吧 Id,String vipId 会员ID
     * <p>返回:{"list":[{VipBarCredit}],"STATUSCODE":true}
     * @see phapp.model.barapp.VipBarCredit
     * @throws Exception
     */
    public void  getBarCreditList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest();
    	String barId = request.getParameter("barId");
    	String vipId = request.getParameter("vipId");
    	if(StringTool.isNull(vipId)==false ) {
    		result.put(STATUSCODE, "8888");
    		result.put(MESSAGE, "数据格式错误");
    	}else{
	    	Map<String,Object> paramMap = new HashMap<String,Object>();
	    	paramMap.put("barId", barId);
	    	paramMap.put("vipId", vipId);
			List<VipBarCredit> list = vipBarCreditManager.findList(paramMap);
			result.put(STATUSCODE, statusCode);
			result.put(MESSAGE, "成功");
			result.put("list", list);
    	}
		outJson(result);
    }
 
    
    
    
    
    
    
    
    
    
    
    

    /**
     * <p>标题: 购买玫瑰花
     * <p>参数: String barId 酒吧Id,String menberId  会员ID,String receiver 接收者(备用)
     * <p>参数: String 	starcount玫瑰花数量, String paymoney成交金额（单位：分）
     * <p>返回:{"list":[{VipBarCredit}],"STATUSCODE":true}
     * @see phapp.model.barapp.VipMain
     * @see phapp.model.barapp.VipJfshjyLog
     * @throws Exception
     */
    public void  buyStar() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest();
    	String barId = request.getParameter("barId");
    	String menberId = request.getParameter("menberId");
    	String receiver = request.getParameter("receiver");
    	String starcount = request.getParameter("starcount");
    	String paymoney = request.getParameter("paymoney");
    	/** 1 */
    	Map<String,Object> paramMap = new HashMap<String,Object>();
    	paramMap.put("id", menberId);
    	paramMap.put("roses", Integer.parseInt(starcount));
    	vipMainManager.updateByMap(paramMap);
    	/** 2 */
    	VipJfshjyLog vipJfshjyLog = new VipJfshjyLog();
 
    	/**分值*/
    	vipJfshjyLog.setTransactions(starcount);
    	/**主动者ID:可为会员ID,酒吧ID*/
    	vipJfshjyLog.setMainId(Integer.parseInt(menberId));
    	   /**接收者ID*/
    	//vipJfshjyLog.setRecipientId(Integer.parseInt(receiver));;
    	   /**状态:1000成功,9999失败*/
    	vipJfshjyLog.setStatus(1000);
    	   /**类型:1积分,2送花,3点赞,4交友,5买花*/
    	vipJfshjyLog.setTypes("5");
    	   /**说明*/
    	vipJfshjyLog.setExplains("5买花");
    	
    	vipJfshjyLogManager.save(vipJfshjyLog);
    	 
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "成功");
		outJson(result);
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
	/*******************************************************/
	/******************   聊天接口      ********************/
	/*******************************************************/    
    
    /**
     * <p>标题: 最近联系人
     * <p>参数: String menberId 会员ID,String limit 取前多少条 ,String control 1:查好友,2:取非好友, String reading 已读未读:1已读,2未读
     * <p>描述: 以字母排序列表
     * <p>返回: {"list":[{BarChatLog}]
     * @see phapp.model.barapp.BarChatLog
     * @see phapp.model.barapp.VipMain
     * @throws Exception
     */
    public void  getSoonFriendList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>();
    	String menberId = request.getParameter("menberId"); 
    	paramMap.put("menberId", menberId); 
    	List<BarChatLog> list = barChatLogManager.getSoonFriendList(paramMap);
    	List listdata = new ArrayList();
    	for(BarChatLog obj : list){
    		Map<String,Object> oneleMap = new HashMap<String,Object>();
    		
    		oneleMap.put("id",obj.getId());
    		oneleMap.put("content" ,obj.getContent());
    		oneleMap.put("menberId" ,obj.getMainId());
    		oneleMap.put("reading" ,obj.getReading());
    		oneleMap.put("annex" ,obj.getAnnex());
    		oneleMap.put("recipientId" ,obj.getRecipientId());
    		oneleMap.put("createTime" ,obj.getCreateTimeString());
    		/**主类处理*/
    		VipMain vipMain = obj.getVipMain(); 
    		oneleMap.put("menberName",vipMain.getMenberName()); 
    		oneleMap.put("elephant" ,vipMain.getElephant());
    		oneleMap.put("nickname" ,vipMain.getNickname());
    		oneleMap.put("sex" ,vipMain.getSex());
    		oneleMap.put( "mood" ,vipMain.getMood());
    		oneleMap.put("constellation" ,vipMain.getConstellation());
    		oneleMap.put("age" ,vipMain.getAge());
    		oneleMap.put("roses", vipMain.getRoses()); 
    		//paramMap.put("file" ,vipMain.getFile());
    		oneleMap.put("pinyin4j" ,vipMain.getPinyin4j());
    		oneleMap.put("email" ,vipMain.getEmail());
    		oneleMap.put("fileType" ,vipMain.getFileType());
    		oneleMap.put("logincount" ,vipMain.getLogincount());
    		listdata.add(oneleMap);
    		 
    	}        	
    	/** HTTP参数处理 end */
		result.put(STATUSCODE, statusCode);
		result.put("list", listdata);
    	outJson(result);
    }


    /**
     * <p>标题: 点赞
     * <p>参数: String custid 被点赞用户id,String mainId 主动赞别的会员ID
     * <p>返回: {"MESSAGE":"谢谢点赞","STATUSCODE":"1000"}
     * @throws Exception
     */
    public void  cutomPraise() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest(); 
    	String menberId = request.getParameter("custid").trim();
    	String mainId = request.getParameter("mainId").trim();
    	if( StringTool.isNull(menberId)==false || StringTool.isNull(mainId)==false ){
	    	result.put(STATUSCODE, "8888");
	    	result.put(MESSAGE, "参数不能为空");
    	}else{
        	/** 1、点赞验证  */
        	Map<String,Object> paramMap3 = new HashMap<String,Object>();
        	paramMap3.put("recipientId",menberId);
        	paramMap3.put("mainId",mainId);
        	paramMap3.put("types",3);
        	paramMap3.put("timelimit","1");
        	List lsitlog = vipJfshjyLogManager.findList(paramMap3); 
        	if(null==lsitlog||lsitlog.size()==0){
    	    	/**修改在线表用户赞数*/
    	    	Map<String,Object> map_param = new HashMap<String,Object>();
    	    	map_param.put("likes","1");
    	    	map_param.put("menberId",menberId);
    	    	map_param.put("mainId",mainId);
    	    	barOnlineManager.updateByMap(map_param);
    	    	/**用户点赞操作日志*/
    	    	VipJfshjyLog vipJfshjyLog = new VipJfshjyLog();
    	    	   /**主动者ID:可为会员ID,酒吧ID*/
    	    	vipJfshjyLog.setMainId(Integer.parseInt(mainId));
    	    	   /**接收者ID*/
    	    	vipJfshjyLog.setRecipientId(Integer.parseInt(menberId));
    	    	   /**状态:1000成功,9999失败*/
    	    	vipJfshjyLog.setStatus(1000);
    	    	   /**类型:1积分,2送花,3点赞,4交友*/
    	    	vipJfshjyLog.setTypes("3");
    	    	   /**说明*/
    	    	vipJfshjyLog.setExplains("点赞:会员‘"+mainId+"’,点赞会员‘:"+menberId+"’一下");
    	    	vipJfshjyLogManager.save(vipJfshjyLog);
    	    	result.put(STATUSCODE, statusCode);
    	    	result.put(MESSAGE, "谢谢点赞");       		
        	}else{
    	    	result.put(STATUSCODE, statusCode);
    	    	result.put(MESSAGE, "你已经点赞过了,一天只能点赞一次");   
        	}
    	}
    	outJson(result);
    }

    /**
     * <p>标题:  	发送图片（聊天） 
	 * @param	接收用户id	recvcustid	整形数
	 * @param	 user 主用户ID 整形数
	 * @param文件类型	filetype	字符串（jpg、gif、png）
	 * @param文件内容	filedata	字符串（base64编码） 
     * <p>返回: {"MESSAGE":"谢谢","STATUSCODE":"1000"}
     * @throws Exception
     */
    public void  sendPic() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest(); 
    	String recvcustid = request.getParameter("recvcustid");
    	String filetype = request.getParameter("filetype");
    	String filedata = request.getParameter("filedata");
    	String mainId = request.getParameter("user");
    	/***/
    	FileManagerService fileserver = new FileManagerService();
    	Map<String,Object> fileMap = new  HashMap<String,Object>();
    	BarChatLog barChatLog = new BarChatLog();
    	if(null!=filetype&&null!=filedata){
    	      fileMap = fileserver.crateBtFile(filedata, filetype,"qq");
       	       /**内容*/
    	    	barChatLog.setContent((String)fileMap.get("absolute"));
    	    	   /**聊天内容附属:拓展用*/
    	    	barChatLog.setAnnex((String)fileMap.get("relatively"));
    	}else{
	    	barChatLog.setContent("");
	    	   /**聊天内容附属:拓展用*/
	    	barChatLog.setAnnex("");	
    	}
		//map.get("btFile");        //BASE6流
		//map.get("absolute");  //绝对
		//map.get("relatively");//相对
     
    	   /**主用户ID*/
    	barChatLog.setMainId(Integer.parseInt( mainId));
    	   /**接收者ID*/
    	barChatLog.setRecipientId(Integer.parseInt( recvcustid) );
    	   /**已读未读:1已读,2未读*/
    	barChatLog.setReading(2);
    	   /**类型:*/
    	//barChatLog.setTypes(filetype);

    	barChatLogManager.save(barChatLog);
    	
    	/**推送表-好比短信下行表*/
    	//lyjFxmsgSendManager
    	LyjFxmsgSend lyjFxmsgsend = new LyjFxmsgSend();
    	   /**消息类型:3图片广本 4赠花*/
    	lyjFxmsgsend.setMsgType(3); 
    	   /**发送者ID*/
    	lyjFxmsgsend.setSendId(Integer.parseInt( mainId));
    	   /**接收者ID*/
    	lyjFxmsgsend.setRecvId(Integer.parseInt( recvcustid) );
    	   /**消息格式:1文本 2图片*/
    	lyjFxmsgsend.setMsgFormat(2);
    	   /**消息内容(图片url)*/
    	lyjFxmsgsend.setMsgContent((String)fileMap.get("relatively"));
    	   /**玫瑰花数量*/
    	lyjFxmsgsend.setFlowerCount(0);
    	//其他初始值，必须要赋值
        lyjFxmsgsend.setMsgLength(0);
        lyjFxmsgsend.setMsgSeqno(0);
        lyjFxmsgsend.setMsgSeqno(0);
        lyjFxmsgsend.setOrigMsgSeqno(0);
        lyjFxmsgsend.setSendCount(0);
        lyjFxmsgsend.setSendStatus(-1);
        
    	lyjFxmsgSendManager.save(lyjFxmsgsend);
    	
    	result.put(STATUSCODE, statusCode);
    	result.put(MESSAGE, "发送成功");
    	outJson(result);
    }


    /**
     * <p>标题:  赠送玫瑰（聊天） 
	 * @param	用户帐号	user	字符串
	 * @param	接收用户id	recvcustid	整形数
	 * @param	数量	flowercount	整形数 
     * <p>返回: {"MESSAGE":"谢谢","STATUSCODE":"1000"}
     * @throws Exception
     */
    public void  sendRose() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest(); 
    	String recvcustid = request.getParameter("recvcustid");
    	int flowercount = null==request.getParameter("flowercount") ? 0 : Integer.parseInt(request.getParameter("flowercount")); 
    	String mainId = request.getParameter("user");
    	/**查询当前用户鲜花数据*/
    	if(StringTool.isNumeric(mainId)==true&&StringTool.isNumeric(recvcustid)==true){
    		LyjFxmsgSend lyjFxmsgsend = new LyjFxmsgSend();
    		BarChatLog barChatLog = new BarChatLog();
    		String content = ""; //barChatLog 内容
	    	VipMain mainvip = vipMainManager.getById(Integer.parseInt(mainId));
	    	VipMain recvvip = vipMainManager.getById(Integer.parseInt(recvcustid));
	    	int mainRoses = mainvip.getRoses();
	    	if(flowercount<=mainRoses){
	    		//可以赠送
		    	Map<String,Object> paramMap1 = new HashMap<String,Object>();
		    	Map<String,Object> paramMap2 = new HashMap<String,Object>();
		    	paramMap1.put("id", mainId);
		    	paramMap1.put("rosess", mainRoses-flowercount);
		    	vipMainManager.updataByMap(paramMap1);
		    	paramMap2.put("id", recvcustid);
		    	paramMap2.put("rosess", recvvip.getRoses()+flowercount);
		    	vipMainManager.updataByMap(paramMap2);
		    	content = mainvip.getMenberName()+"赠送"+flowercount+"花,给"+recvvip.getMenberName()+"";
		    	result.put(STATUSCODE, statusCode);
		    	result.put(MESSAGE, "谢谢赠送");
	    	}else{
	    		content = "您的数量不够";
		    	result.put(STATUSCODE, "8888");
		    	result.put(MESSAGE, content);
	    	}
	    	
    		/**写日志表*/
	    	barChatLog.setMainId(Integer.parseInt( mainId));/**主用户ID*/
	    	barChatLog.setRecipientId(Integer.parseInt( recvcustid) ); /**接收者ID*/
	    	barChatLog.setReading(2);/**已读未读:1已读,2未读*/
	    	//barChatLog.setTypes(filetype);/**类型:*/ 
	    	barChatLog.setContent(content); /**内容*/ 
	    	barChatLogManager.save(barChatLog);/**聊天内容附属:拓展用*/ 	    	
	    	/**推送表-好比短信下行表*/ 
	    	lyjFxmsgsend.setMsgType(4); /**消息类型:3图片广本 4赠花*/ 
	    	lyjFxmsgsend.setSendId(Integer.parseInt( mainId));/**发送者ID*/ 
	    	lyjFxmsgsend.setRecvId(Integer.parseInt( recvcustid) ); /**接收者ID*/ 
	    	//lyjFxmsgsend.setMsgFormat(2); /**消息格式:1文本 2图片*/ 
	    	lyjFxmsgsend.setFlowerCount(flowercount); /**玫瑰花数量*/ 
	    	lyjFxmsgsend.setMsgContent(content);
	    	//其他初始值，必须要赋值
	        lyjFxmsgsend.setMsgLength(0);
	        lyjFxmsgsend.setMsgSeqno(0);
	        lyjFxmsgsend.setMsgSeqno(0);
	        lyjFxmsgsend.setOrigMsgSeqno(0);
	        lyjFxmsgsend.setSendCount(0);
	        lyjFxmsgsend.setSendStatus(-1); 
	    	lyjFxmsgSendManager.save(lyjFxmsgsend);
	    	/***/

    	}else{
        	result.put(STATUSCODE, "8888");
        	result.put(MESSAGE, "参数格式错误");   		
    	}

    	outJson(result);
    }
    
    
    

	/*******************************************************/
	/******************     商家接口    ********************/
	/*******************************************************/

    /**
     * <p>标题: 商家列表(所有)数据
     * <p>参数: 
     * <p>返回:{"list":[{ShopMain}],"STATUSCODE":true}
     * @see phapp.model.barapp.ShopMain
     * @throws Exception
     */
    public void  getShopAllList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest(); 
		List<ShopMain> list = shopMainManager.findAll();
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "成功");
		result.put("list", list);
		outJson(result);
    }
    
    /**
     * <p>标题: 所有商品列表数据
     * <p>参数: String shopId  商家 Id,"不传参数则查询所有"
     * <p>返回: 
     * @see phapp.model.barapp.ShopGood
	 * @see phapp.model.barapp.ShopMain
     * @throws Exception
     */
    public void  getShopGoodList() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>(); 
    	String shopId = request.getParameter("shopId"); 
    	paramMap.put("shopId", shopId); 
		List<ShopGood> list = shopGoodManager.findList(paramMap);
		result.put(STATUSCODE, statusCode);
		result.put(MESSAGE, "成功");
		result.put("list", list);
		outJson(result);
    }

    /**
     * <p>标题: 酒吧积分-积分兑换(兑换业务不清楚)
     * <p>参数: String credit积分,String barId酒吧ID,String vipId会员ID,String password积分兑换密码
     * <p>返回: vip_bar_credit
     * @throws Exception
     */
    public void  barCreditConvert() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */    	 
    	HttpServletRequest request = getRequest();
    	Map<String,String> paramMap = new HashMap<String,String>(); 
    	String credit = request.getParameter("credit");
    	String barId = request.getParameter("barId");
    	String vipId = request.getParameter("vipId");
    	String password = request.getParameter("password");
    	/** HTTP参数处理 end */
    	/**密码验证 begin*/
    	
    	/**密码验证 end*/
    	/**新增积分*/
    	VipBarCredit vipBarCredit = new VipBarCredit();
    	vipBarCredit.setBarId(Integer.parseInt( barId));
    	vipBarCredit.setCredit(Integer.parseInt( credit));
    	vipBarCredit.setVipId(Integer.parseInt( vipId ));
    	
    	vipBarCreditManager.updateBySelective(vipBarCredit);
    	result.put(STATUSCODE, statusCode);
    	result.put(MESSAGE, statusCode);
    	outJson(result);
    }    
    
    
    
    
	/*******************************************************/
	/******************     辅助接口    ********************/
	/*******************************************************/
 
    /**
     * <p>标题:  意见|反馈|留言-提交接口
     * <p>参数: String types 类型:1意见,2反馈,3留言,4其它,String userId 会员ID, String content 内容
     * <p>返回: {"MESSAGE":"","STATUSCODE":"1000"}
     * @throws Exception submitFeedbac
     */
    public void  submitFeedbac() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();
    	/** HTTP参数处理 begin */
    	Map<String,Object> paramMap = new HashMap<String,Object>();
    	paramMap = getParamMap();
    	/** HTTP参数处理 end */
    	/**MAP TO POJO*/
    	Feedback feedback = (Feedback)MapForObj.convertMap(Feedback.class, paramMap);
    	feedbackManager.save(feedback);
    	result.put(STATUSCODE, statusCode);
    	result.put(MESSAGE, "提交成功");
    	outJson(result);
    }    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    /**
     * <p>标题: 接口示例
     * <p>参数:
     * <p>返回: {"list":[{}],"STATUSCODE":true}
     * @throws Exception
     */
    public void  testxxxx() throws Exception{
    	Map<String,Object> result = new HashMap<String,Object>();

    	outJson(result);
    }

	/**
	 *  <p>标题：下拉框所用 列表 
	 * @throws IOException
	 */
	public void getComboBox() throws IOException { 
		Map<String, Object> result = new HashMap<String, Object>();
		 
			String str = "";
			Bars barsobj = new Bars();
			List<Bars> list = barsManager.findAll();
	        result.put("success", false);
	        result.put("list", list);
		 
	        myWriterJson(result);
	}


}
